<div class="wrapper-md ng-scope">
<div class="row" novalidate>

    <div class="panel panel-default">
      <tabset class="tab-container" >

        <tab heading="角色列表" ng-click="cancel()" active="status.rolelist">
          <div class="row wrapper" >
            <div class="col-lg-4">
              <div class="input-group" >
                <div class="input-group-btn" >
                  <span class="btn btn-default">角色名称</span>
                </div>
                <input type="text" class="form-control" ng-model="search.aname">
              </div>
            </div>
            <div class="col-lg-4">
              <div class="input-group" >
                <div class="input-group-btn" >
                  <span class="btn btn-default">英文名称</span>
                </div>
                <input type="text" class="form-control" ng-model="search.enname">
              </div>
            </div>
            <button class="btn m-b-xs w-xs btn-success" ng-click="search()">搜索</button>
          </div>

          <div class="panel-body">
            <table class="table table-striped table-bordered ng-isolate-scope dataTable no-footer" 
              style="display: table; width: 100%;table-layout:fixed;">
              <thead>
                <tr>
                  <th style="width: 10%;text-align:center;">角色名称</th>
                  <th style="width: 10%;text-align:center;">英文名称</th>
                  <th style="width: 8%;text-align:center;">归属机构</th>
                  <th style="width: 9%;text-align:center;">数据范围</th>
                  <th style="width: 10%;text-align:center;">操作</th>
                </tr>
              </thead>
              <tbody>
                <tr ng-repeat="info in role_list">
                  <td align="center">{{info.name}}</td>
                  <td align="center">{{info.enname}}</td>
                  <td align="center">{{info.office_name}}</td>
                  <td align="center">{{info.data_scope_name}}</td>
                  <td>
                    <button type="button" class="btn btn-info btn-xs" ng-click="allot(info)">分配</button>
                    <button type="button" class="btn btn-info btn-xs" ng-click="update(info)">修改</button>
                    <button type="button" class="btn btn-info btn-xs" ng-click="setAuth(info)">授权</button>
                    <button type="button" class="btn btn-info btn-xs" ng-click="setTemplete(info)">设置模板</button>
                    <button type="button" class="btn btn-info btn-xs" ng-click="setDict(info)">设置销售品</button>
                    <button type="button" class="btn btn-info btn-xs" ng-click="setChannel(info)">绑定渠道</button>
                    <button type="button" class="btn btn-danger btn-xs" ng-click="delete(info)">删除</button>
                  </td>
                </tr>
              </tbody>
            </table>
          </div>
        </tab>

        <tab heading="{{tabname.name}}" ng-click="add()" ng-if="what != 'allot'" active="tabname.active">
          <div class="panel-body">
            <form name="form1" class="form-horizontal form-validation ng-pristine ng-valid ng-valid-required">
              <!--<div class="form-group">
                <label class="col-lg-2 control-label">归属机构:</label>
                <div class="col-lg-4">
                  <ui-select ng-model="obj.office_id" theme="bootstrap">
                    <ui-select-match placeholder="必填">{{$select.selected.name}}</ui-select-match>
                    <ui-select-choices repeat="item.id as item in offList | filter: $select.search">
                      <span ng-bind-html="item.name | highlight: $select.search"></span>
                    </ui-select-choices>
                  </ui-select>
                </div>
              </div>-->
              <div class="form-group">
                <label class="col-lg-2 control-label">角色名称:</label>
                <div class="col-lg-4">
                  <input type="text" class="form-control" placeholder="必填" ng-model="obj.name">
                </div>
              </div>
              <div class="form-group">
                <label class="col-lg-2 control-label">英文名称:</label>
                <div class="col-lg-4">
                  <input type="text" class="form-control" placeholder="必填" ng-model="obj.enname">
                </div>
              </div>
              <!--<div class="form-group">
                <label class="col-lg-2 control-label">角色类型:</label>
                <div class="col-lg-3">
                  <ui-select ng-model="obj.role_type" theme="bootstrap">
                    <ui-select-match placeholder="必填">{{$select.selected.name}}</ui-select-match>
                    <ui-select-choices repeat="item.id as item in role_type_list | filter: $select.search">
                      <span ng-bind-html="item.name | highlight: $select.search"></span>
                    </ui-select-choices>
                  </ui-select>
                </div>
                <label class="control-label text-muted">工作流组用户组类型（任务分配：assignment、管理角色：security-role、普通角色：user）</label>
              </div>-->
              <div class="form-group">
                <label class="col-lg-2 control-label">系统数据:</label>
                <div class="col-lg-8">
                  <div class="radio">
                    <label class="i-checks">
                      <input type="radio" ng-model="obj.is_sys" value="1"><i></i>是
                    </label>
                    <label class="i-checks" style="margin-left: 10px">
                      <input type="radio" ng-model="obj.is_sys" value="0"><i></i>否
                    </label>
                    <label class="control-label text-muted">“是”代表此数据只有超级管理员能进行修改，“否”则表示拥有角色修改人员的权限都能进行修改</label>
                  </div>
                </div>
              </div>
              <div class="form-group">
                <label class="col-lg-2 control-label">是否可用:</label>
                <div class="col-lg-4">
                  <label class="i-switch m-t-xs m-r">
                    <input type="checkbox" ng-true-value="'1'" ng-false-value="'0'" ng-model="obj.useable">
                    <i></i>
                  </label>
                </div>
              </div>
              <div class="form-group">
                <label class="col-lg-2 control-label">数据范围:</label>
                <div class="col-lg-3">
                  <ui-select ng-model="obj.data_scope" theme="bootstrap">
                    <ui-select-match placeholder="必填">{{$select.selected.name}}</ui-select-match>
                    <ui-select-choices repeat="item.id as item in data_scope_list | filter: $select.search">
                      <span ng-bind-html="item.name | highlight: $select.search"></span>
                    </ui-select-choices>
                  </ui-select>
                </div>
                <label class="control-label text-muted">特殊情况下，设置为“按明细设置”，可进行跨机构授权</label>
              </div>
              <div class="form-group">
                <label class="col-lg-2 control-label">生效范围:</label>
                <div class="col-lg-2">
                  <select class="form-control ng-pristine ng-valid ng-touched" ng-model="obj.auth_start">
                    <option value="1">1</option>
                    <option value="2">2</option>
                    <option value="3">3</option>
                    <option value="4">4</option>
                    <option value="5">5</option>
                    <option value="6">6</option>
                    <option value="7">7</option>
                    <option value="8">8</option>
                    <option value="9">9</option>
                    <option value="99">MAX</option>
                  </select>
                </div>
                <!--<div class="col-lg-1 control-label">起-止</div>-->
                <div class="col-lg-2">
                  <select class="form-control ng-pristine ng-valid ng-touched" ng-model="obj.auth_end">
                    <option value="1">1</option>
                    <option value="2">2</option>
                    <option value="3">3</option>
                    <option value="4">4</option>
                    <option value="5">5</option>
                    <option value="6">6</option>
                    <option value="7">7</option>
                    <option value="8">8</option>
                    <option value="9">9</option>
                    <option value="99">MAX</option>
                  </select>
                </div>
                <label class="control-label text-muted">设置角色的生效范围，用于控制菜单的显示范围</label>
              </div>
              <div class="form-group">
                <label class="col-lg-2 control-label">备注:</label>
                <div class="col-lg-4">
                  <textarea id="remarks" class="form-control" rows="3" ng-model="obj.remarks"></textarea>
                </div>
              </div>
            </form>

            <div class="col-lg-2"></div>
            <div class="col-lg-3">
              <button class="btn btn-primary btn-rounded" ng-click="save()">保存</button>
              <button class="btn btn-default btn-rounded" ng-click="cancel()">取消</button>
            </div>
          </div>
        </tab>

        <tab heading="角色分配" ng-if="what == 'allot'" active="status.allot">
          <div class="panel-header">
            <div class="row wrapper" >
              <div class="col-sm-4 control-label">角色名称:  <strong ng-bind-html="obj.name"></strong></div>
              <div class="col-sm-4 control-label">英文名称:  <strong ng-bind-html="obj.enname"></strong></div>
              <div class="col-sm-4 control-label">角色类型:  <strong ng-bind-html="obj.role_type"></strong></div>
              <div class="col-sm-4 control-label">数据范围:  <strong ng-bind-html="obj.data_scope_name"></strong></div>
            </div>
          </div>
          <div class="row wrapper" >
            <div class="col-sm-6 m-b-xs">
              <button class="btn m-b-xs w-xs btn-info btn-rounded" ng-click="allotuser()">角色分配</button>
            </div>
          </div>

          <!--  数据表格  -->
          <table class="table table-striped table-bordered ng-isolate-scope dataTable no-footer" 
            style="display: table; width: 100%;table-layout:fixed;">
            <thead>
              <tr>
                <th style="width: 10%;text-align:center;">归属公司</th>
                <th style="width: 8%;text-align:center;">登录名</th>
                <th style="width: 8%;text-align:center;">姓名</th>
                <th style="width: 5%;text-align:center;">电话</th>
                <th style="width: 5%;text-align:center;">手机</th>
                <th style="width: 4%;text-align:center;">操作</th>
              </tr>
            </thead>
            <tbody>
              <tr ng-repeat="info in user_list">
                <td align="center">{{info.company_name}}</td>
                <td align="center">{{info.login_name}}</td>
                <td align="center">{{info.name}}</td>
                <td align="center">{{info.phone}}</td>
                <td align="center">{{info.mobile}}</td>
                <td align="center">
                  <button type="button" class="btn btn-danger btn-xs" ng-click="remove(info)">移除</button>
                </td>
              </tr>
            </tbody>
          </table>

        </tab>

      </tabset>

      
      

      



    </div>

</div>
</div>


